from django.db import models


# Create your models here.
class Student(models.Model):
    gender_choices = (('男', '男'), ('女', '女'))
    sno = models.IntegerField(db_column="SNo", primary_key=True, null=False)  # 学号，不允许为空
    name = models.CharField(verbose_name="姓名", db_column="SName", max_length=100, null=False)  # 姓名，最长100，不允许为空
    gender = models.CharField(db_column="Gender", max_length=100, choices=gender_choices)  # 性别
    birthday = models.DateField(db_column="Birthday", null=False)  # 出生日期，不允许为空
    mobile = models.CharField(db_column="Mobile", max_length=100)  # 手机号码,
    email = models.CharField(db_column="Email", max_length=100)  # 邮箱地址
    address = models.CharField(db_column="Address", max_length=200)  # 家庭住址
    image = models.CharField(db_column="Image", max_length=200, null=True)  # 照片
    objects = models.Manager()

    # 在默认情况下，生成的表名：App_class，如果要自定义，需要使用class Meta来自定义
    class Meta:
        managed = True
        db_table = "Student"

    # _str_方法
    def __str__(self):
        return "学号:%s\t姓名:%s\t性别:%s" % (self.sno, self.name, self.gender)
